import { Dictionary } from "../../Common/Dictionary";
import ADQ from "../../Core/ADQ";
import { IDataContainer } from "../../Interfaces/IDataTable";
import { IDictionary } from "../../Interfaces/IUtils";

/**数据容器扩展 */
export default class DataContainer implements IDataContainer {
  public constructor(dataName: string) {
    this.dataName = dataName;
    this.dataList = new Dictionary<number, any>();
  }
  dataList: IDictionary<number, any>;
  dataName: string;

  get(id: number): any {
    return this.dataList.get(id);
  }
  set(data: any) {
    this.dataList.set(data[ADQ.IdName], data);
  }

  remove(id: number): boolean {
    return this.dataList.remove(id);
  }
}
